// components/blog-card/blog-card.js
const formatTime = require("../../utils/formatTime.js");
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    blog: Object
  },

  observers: {
    ["blog.createTime"](time) {
      this.setData({
        createTime: formatTime(new Date(time))
      });
    }
  },

  lifetimes: {
    ready() {
      // console.log(this.properties.blog);
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    createTime: ""
  },

  /**
   * 组件的方法列表
   */
  methods: {
    // 预览图像
    onPreviewImage(e) {
      // console.log(e);
      let img = e.currentTarget.dataset.img;
      wx.previewImage({
        current: img,
        urls: this.properties.blog.img
      });
    },
  }
})